<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>米塔云平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../customize/css/iconfont.css">
    <link rel="stylesheet" href="../customize/css/custom.css" media="all">
    <style>
        .layui-layout-admin .layui-logo {
            background-color: #226A62 !important;
        }
    </style>
</head>
<body class="layui-layout-body">
<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item layadmin-flexible" lay-unselect>
                    <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                    </a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a href="javascript:;" layadmin-event="refresh" title="刷新">
                        <i class="layui-icon layui-icon-refresh-3"></i>
                    </a>
                </li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:;" layadmin-event="fullscreen" title="全屏">
                        <i class="layui-icon layui-icon-screen-full"></i>
                    </a>
                </li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:;" onclick="jump()">
                        <i class="layui-icon layui-icon-website"></i> 大屏展示
                    </a>
                </li>
                <!-- <li class="layui-nav-item layui-hide-xs" lay-unselect>
                  <input type="text" placeholder="搜索..." autocomplete="off" class="layui-input layui-input-search" layadmin-event="serach" lay-action="template/search.html?keywords=">
                </li> -->
            </ul>
            <ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right">
                <li class="layui-nav-item" lay-unselect>
                    <a id="e_Total"><i class="iconfont icon-qiyeshuliang"></i> 企业数量：0</a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a id="dTotal">设备总数：0</a>
                </li>
                <li class="layui-nav-item" lay-unselect>
                    <a class="device-status">
                        <span class="text-powerOn" id="total1">运行中：0</span>
                        <span class="text-standby" id="total2">空闲：0</span>
                        <span class="text-powerOff" id="total3">离线：0</span>
                        <span class="text-fault" id="total4">报警：0</span>
                    </a>
                </li>
                <li shiro:hasPermission="history:warn" class="layui-nav-item" lay-unselect>
                    <a lay-href='/pages/alarm' class="layHref" layadmin-event="message" lay-text="系统报警">
                        <i class="layui-icon layui-icon-notice"></i>
                        <!-- 如果有新消息，则显示小圆点 -->
                        <!-- <span class="layui-badge-dot"></span> -->
                    </a>
                </li>
                <li class="layui-nav-item" lay-unselect style="margin-right: 10px;">
                    <a href="javascript:;">
                        <cite>欢迎你，<span id="userInfo"></span></cite>
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" lay-href="userInfo.html">用户信息</a></dd>
                        <hr>
                        <dd><a href="javascript:;" onclick="logout()">退出</a></dd>
                    </dl>
                </li>
            </ul>
        </div>

        <!-- 侧边菜单 -->
        <div class="layui-side layui-side-menu">
            <div class="layui-side-scroll">
                <a class="layui-logo" href="https://mitaiot.com/" target="_blank">
                    <img src="../customize/images/logo0.png">
                </a>
                <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu"
                    lay-filter="layadmin-system-side-menu">
                    <li shiro:hasAnyPermissions="index:map,index:deviceList" data-name="jkzy"
                        class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;" lay-tips="监控主页" lay-direction="2">
                            <i class="iconfont icon-moren25"></i>
                            <cite>监控主页</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd shiro:hasPermission="index:map" data-name="jkzy1" class="layui-this">
                                <a href="javascript:;" lay-href="/pages/gis" class="layHref"><i
                                        class="iconfont icon-xiaolan20"></i>设备地图</a>
                            </dd>
                            <dd shiro:hasPermission="index:deviceList" data-name="jkzy2">
                                <a href="javascript:;" lay-href="/pages/deviceList" class="layHref"><i
                                        class="iconfont icon-left-nav1-2"></i>设备列表</a>
                            </dd>
                        </dl>
                    </li>
                    <li shiro:hasAnyPermissions="history:warn,history:data,history:record" data-name="lssj"
                        class="layui-nav-item">
                        <a href="javascript:;" lay-tips="历史数据" lay-direction="2">
                            <i class="iconfont icon-left-nav2"></i>
                            <cite>历史数据</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd shiro:hasPermission="history:warn" data-name="lssj1">
                                <a href="javascript:;" lay-href="/pages/alarm" class="layHref"><i
                                        class="iconfont icon-xiaolan22 "></i>历史告警</a>
                            </dd>
                            <dd shiro:hasPermission="history:data" data-name="lssj2">
                                <a href="javascript:;" lay-href="/pages/historyData" class="layHref"><i
                                        class="iconfont icon-xiaolan19 "></i>历史数据</a>
                            </dd>
                            <dd shiro:hasPermission="history:record" data-name="lssj3">
                                <a href="javascript:;" lay-href="/pages/messageLog" class="layHref"><i
                                        class="iconfont icon-xiaohui20 "></i>消息推送记录</a>
                            </dd>
                            <!-- <dd data-name="lssj4">
                              <a href="javascript:;" lay-href="table.html"><i class="iconfont icon-xiaolan"></i>报表分析</a>
                            </dd> -->
                        </dl>
                    </li>
                    <li shiro:hasAnyPermissions="device:proc:view,device:proc:opera,device:sensor:view,device:sensor:opera,device:proc:maintenance:view,device:proc:maintenance:opera,device:sensor:maintenance:view,device:sensor:maintenance:opera"
                        data-name="sbgl" class="layui-nav-item">
                        <a href="javascript:;" lay-tips="设备管理" lay-direction="2">
                            <i class="iconfont icon-xiaolan6"></i>
                            <cite>设备管理</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd shiro:hasAnyPermissions="device:proc:view,device:proc:opera" data-name="sbgl1">
                                <a href="javascript:;" lay-href="/pages/prdEquManagement" class="layHref"><i
                                        class="iconfont icon-xiaolan7 "></i>生产设备管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="device:sensor:view,device:sensor:opera" data-name="sbgl2">
                                <a href="javascript:;" lay-href="/pages/acqEquManagement" class="layHref"><i
                                        class="iconfont icon-xiaolan2 "></i>采集设备管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="device:proc:maintenance:view,device:proc:maintenance:opera"
                                data-name="sbgl3">
                                <a href="javascript:;" lay-href="/pages/prdEquMaintenance" class="layHref"><i
                                        class="iconfont icon-xiaolan22 "></i>生产设备维保管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="device:sensor:maintenance:view,device:sensor:maintenance:opera"
                                data-name="sbgl4">
                                <a href="javascript:;" lay-href="/pages/acqEquMaintenance" class="layHref"><i
                                        class="iconfont icon-xiaolan1 "></i>采集设备病例</a>
                            </dd>
                        </dl>
                    </li>
                    <li shiro:hasAnyPermissions="enterprise:info:view,enterprise:info:opera,enterprise:time:view,enterprise:time:opera"
                        data-name="qygl" class="layui-nav-item">
                        <a href="javascript:;" lay-tips="企业管理" lay-direction="2">
                            <i class="iconfont icon-xiaolan4"></i>
                            <cite>企业管理</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd shiro:hasAnyPermissions="enterprise:info:view,enterprise:info:opera" data-name="qygl1">
                                <a href="javascript:;" lay-href="/pages/companyManagement" class="layHref"><i
                                        class="iconfont icon-xiaolan5 "></i>企业信息管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="enterprise:time:view,enterprise:time:opera" data-name="qygl2">
                                <a href="javascript:;" lay-href="/pages/timeManagement" class="layHref"><i
                                        class="iconfont icon-xiaolan9 "></i>作息时间管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="enterprise:group:view,enterprise:group:poera"
                                data-name="qygl3">
                                <a href="javascript:;" lay-href="/pages/deviceGroup" class="layHref"><i
                                        class="iconfont icon-shebeifenzuguanli "></i>设备分组管理</a>
                            </dd>
                        </dl>
                    </li>
                    <!--                    <li shiro:hasAnyPermissions="bank:info:view,bank:info:opera,bank:inner:view,bank:inner:opera" data-name="yhgl" class="layui-nav-item">
                                            <a href="javascript:;" lay-tips="银行管理" lay-direction="2">
                                                <i class="iconfont icon-xiaolan12"></i>
                                                <cite>银行管理</cite>
                                            </a>
                                            <dl class="layui-nav-child">
                                                <dd shiro:hasAnyPermissions="bank:info:view,bank:info:opera" data-name="yhgl1">
                                                    <a href="javascript:;" lay-href="/pages/bankInfoManagement"><i
                                                            class="iconfont icon-xiaolan14"></i>银行信息管理</a>
                                                </dd>
                                                <dd shiro:hasAnyPermissions="bank:inner:view,bank:inner:opera" data-name="yhgl2">
                                                    <a href="javascript:;" lay-href="/pages/bankInternalManagement"><i
                                                            class="iconfont icon-xiaolan13"></i>银行内部管理</a>
                                                </dd>
                                            </dl>
                                        </li>-->
                    <li shiro:hasAnyPermissions="sys:user:view,sys:user:opera,sys:role:view,sys:role:opera,sys:type:view,sys:type:opera"
                        data-name="qxgl" class="layui-nav-item">
                        <a href="javascript:;" lay-tips="权限管理" lay-direction="2">
                            <i class="iconfont icon-xiaolan8"></i>
                            <cite>权限管理</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd shiro:hasAnyPermissions="sys:user:view,sys:user:opera" data-name="qxgl1">
                                <a href="javascript:;" lay-href="/pages/roleManagement" class="layHref"><i
                                        class="iconfont icon-xiaolan10 "></i>角色管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="sys:role:view,sys:role:opera" data-name="qxgl2">
                                <a href="javascript:;" lay-href="/pages/usersManagement" class="layHref"><i
                                        class="iconfont icon-xiaolan16 "></i>用户管理</a>
                            </dd>
                            <dd shiro:hasAnyPermissions="sys:type:view,sys:type:opera" data-name="qxgl3">
                                <a href="javascript:;" lay-href="/pages/typeManagement" class="layHref"><i
                                        class="iconfont icon-shebeileixingguanli "></i>设备类型管理</a>
                            </dd>
                        </dl>
                    </li>
                    <li shiro:hasAnyPermissions="system,system:log" data-name="xtgl" class="layui-nav-item">
                        <a href="javascript:;" lay-tips="系统管理" lay-direction="2">
                            <i class="iconfont icon-xiaolan11"></i>
                            <cite>系统管理</cite>
                        </a>
                        <dl class="layui-nav-child">
                            <dd shiro:hasAnyPermissions="system:log" data-name="xtgl1">
                                <a href="javascript:;" lay-href="/pages/systemLog" class="layHref"><i
                                        class="iconfont icon-xiaolan15 "></i>后台操作日志</a>
                            </dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>

        <!-- 页面标签 -->
        <div class="layadmin-pagetabs" id="LAY_app_tabs">
            <div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-down">
                <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;"></a>
                        <dl class="layui-nav-child layui-anim-fadein">
                            <dd layadmin-event="closeThisTabs"><a href="javascript:;">关闭当前标签页</a></dd>
                            <dd layadmin-event="closeOtherTabs"><a href="javascript:;">关闭其它标签页</a></dd>
                            <dd layadmin-event="closeAllTabs"><a href="javascript:;">关闭全部标签页</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
            <div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                <ul class="layui-tab-title" id="LAY_app_tabsheader">
                    <li lay-id="/pages/gis" lay-attr="/pages/gis" class="layui-this" id="pagesGisLi"><i
                            class="iconfont icon-xiaolan20"></i>
                        设备地图
                    </li>
                </ul>
            </div>
        </div>


        <!-- 主体内容 -->
        <div class="layui-body" id="LAY_app_body">
            <div class="layadmin-tabsbody-item layui-show">
                <iframe src="" frameborder="0" class="layadmin-iframe" id="pagesGisIf"></iframe>
            </div>
        </div>

        <!-- 辅助元素，一般用于移动设备下遮罩 -->
        <div class="layadmin-body-shade" layadmin-event="shade"></div>
    </div>
</div>
<script src="../plugins/jquery-3.4.1.min.js"></script>
<script src="../layuiadmin/layui/layui.js"></script>
<script src="../plugins/alert.js"></script>
<script src="../customize/js/common.js"></script>
<script src="../customize/js/CommonUtils.js"></script>
<script>
    window.onload = function () {
        if (top.location.href != window.location.href) {
            // top.location.href = "/pages/index.html";
            top.location.href = '../index.html';
        }
    };
    var getToken = getQueryString("token");
    if (!isNull(getToken)) {
        sessionStorage.setItem("token", getToken);
    }
    let token = sessionStorage.getItem("token");
    let layHrefS = $('.layHref');
    let pagesGisLi = $('#pagesGisLi').attr("lay-id");
    $('#pagesGisLi').attr("lay-id", pagesGisLi + "?token=" + token);
    $('#pagesGisIf').attr("src", "/pages/gis?token=" + token);
    for (let lay of layHrefS) {
        let href = $(lay).attr("lay-href");
        let newHref = href + "?token=" + token;
        $(lay).attr("lay-href", newHref);
    }

    if (isNull(sessionStorage.getItem("token"))) {
        myAlert("提示", "请登录后访问", function () {
            sessionStorage.setItem("isLogin", "false");
            top.location.href = "../index.html";
        })
    }

    function jump() {
        let token = sessionStorage.getItem("token");
        window.open(dpUrl + "?token=" + token);
    }

    $(function () {
        userInfo();
        getETotal();
        getDeviceTotal();
    });

    function logout() {
        getJson('/sys/logout', {token:sessionStorage.getItem("token")}, 'GET', function (data) {
            myAlert('提示', data['message'], function () {
                sessionStorage.clear();
                top.location.href = '../index.html';
            });
        })
    }

    function userInfo() {
        getJson('/sys/userInfo', null, 'GET', function (data) {
            $('#userInfo').text(data['payload']['data']['displayName']);
        })
    }

    //获取企业数量
    function getETotal() {
        getJson("/enterprise/countEnterprise", null, 'GET', function (result) {
            if (result.code == 200) {
                $('#e_Total').html("企业数量：" + result.payload.data.value);
            } else {
                myAlert("提示", result.message);
            }
        })

    }

    /*获取设备数量与各个设备状态数量*/
    function getDeviceTotal() {
        getJson("/device/getDeviceTotal", null, 'GET', function (result) {
            if (result.code == 200) {
                let dTotal = 0;
                let total1 = 0;
                let total2 = 0;
                let total3 = 0;
                let total4 = 0;
                for (let i = 0; i < result.payload.data.length; i++) {
                    let data = result.payload.data[i];
                    if (data.name == "设备总数") {
                        dTotal = data.value;
                    } else if (data.name == 1) {
                        total1 = data.value;
                    } else if (data.name == 2) {
                        total2 = data.value;
                    } else if (data.name == 3) {
                        total3 = data.value;
                    } else if (data.name == 4) {
                        total4 = data.value;
                    }
                }
                $('#dTotal').html('设备总数：' + dTotal);
                $('#total1').html('运行中：' + total1);
                $('#total2').html('空闲：' + total2);
                $('#total3').html('离线：' + total3);
                $('#total4').html('报警：' + total4);
            } else {
                myAlert("提示", result.message);
            }
        })
    }
</script>
<script>
    layui.config({
        base: '../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use('index');
</script>
</body>
</html>


